@extends('home.index.layout')

@section('content')
<script src="{{url('/ho/js/event.js')}}"></script>
<link href="{{url('/ho/css/themes.css')}}" rel="stylesheet" type="text/css">
<div class="wrap">
        <!--面包屑-->
        <div class="crumbs"><a class="ml0" href="">首页</a>&gt;<a href="" class="j_ygnav">我的易果</a><span class="j_thridcrumbs hide">&gt;<a href="{{url('/user/detail')}}" class="on j_thirdnav">个人资料</a></span></div>
    <div class="content myyg">
            <div class="sub">
                <div class="menu j_menu">
                    <dl>
                        <dt>交易信息</dt>
                        <dd>
                            <ul>
                                <li><a href="{{url('/order/index')}}">我的订单</a></li>
                                
                                <li><a href="">我的金币</a></li>
                                
                                
                                
                                <li><a href="">购买过的商品</a></li>
                                <li><a href="{{url('/user/favorite')}}">我的收藏</a></li>
                                <li><a href="">评论商品</a></li>
                            </ul>
                        </dd>
                        <dt>账号信息</dt>
                        <dd>
                            <ul>
                                <li><a href="">账户余额</a></li>
                                <li>
                                    <a href="{{url('/user/detail')}}">个人资料</a>
                                        <img style="height: 19px; width: 20px; margin-left: 10px;" src="{{url('/ho/imgs/icon-gift.png')}}">
                                </li>
                                <li><a href="">账号安全</a></li>
                                <li><a href="{{url('/user/address')}}">收货地址管理</a></li>  
                            </ul>
                        </dd>
                        <dt>售后服务</dt>
                        <dd>
                            <ul>
                                <li><a href="">在线退换货</a></li>
                                <li><a href="">投诉建议</a></li>
                            </ul>
                        </dd>
                    </dl>
                </div>
                <div>
                    <div class="ad" style="height: 308px;">
                        <a href="#" target="_blank" style="display: none"><img src="{{url('/ho/imgs/ad.jpg')}}" width="194" height="308"></a>
                    </div>
                </div>
            </div>

<div class="main profile">
    <div class="title">个人资料</div>
    <div>
        <div class="sub-tit">基本信息</div>
        <form id="personalProfileForm" action="{{url('/user/update')}}" method="post" enctype="multipart/form-data">
            {{ csrf_field() }}
            <div class="control-group">
                <div class="control-label">头像</div>
                <div class="controls">
                    <a href="javascript:" id="btnUpload">
                        <img style=" width:100px; height:100px;" src="{{url('/uploads/yhtx')}}/{{session('home')->pic ? session('home')->pic :"default.jpg"}}" />
                    </a>
                </div>
            </div>
            <div class="control-group">
                <div class="control-label">新头像</div>
                <div class="controls">
                        <input id="uploadPic" type="file" name="pic" />
                <div id="upload_prev">
                </div>
                    
                </div>
            </div>
            <div class="control-group">
                <div class="control-label">真实姓名</div>
                <div class="controls">
                    <span class="EidtGroup">
                        <input class="input" id="RealName" name="name" placeholder="请输入您的真实姓名" type="text" value="{{!empty(session('home')->name)? session('home')->name : ''}}" />
                        <span class="pass-tip"></span>
                    </span>
                </div>
            </div>
            <div class="control-group">
                <div class="control-label">昵称</div>
                <div class="controls">
                    <span class="EidtGroup">
                        <input class="input" id="nickname" name="nickname" placeholder="请输入您的昵称" type="text" value="{{!empty(session('home')->nickname)? session('home')->nickname : ''}}" />
                        <span class="pass-tip"></span>
                    </span>
                </div>
            </div>
            <div class="control-group">
                <div class="control-label">手机</div>
                <div class="controls">
                    <span class="EidtGroup">
                        <input class="input" id="phone" name="phone" placeholder="请输入您的手机号" type="text" value="{{!empty(session('home')->phone)? session('home')->phone : ''}}" />
                        <span class="pass-tip"></span>
                    </span>
                </div>
            </div>
            <div class="control-group">
                <div class="control-label">邮箱</div>
                <div class="controls">
                    <span class="EidtGroup">
                        <input class="input" id="email" name="email" placeholder="请输入您的邮箱" type="text" oldValue ="{{!empty(session('home')->email)? session('home')->email : ''}}" value="{{!empty(session('home')->email)? session('home')->email : ''}}" />
                        <span class="pass-tip"></span>
                    </span>
                </div>
            </div>
            <div class="sub-tit">选填信息</div>
            <div class="control-group">
                <div class="control-label">性别</div>
                <div class="controls">
                    <label><input data-val="true" data-val-number="字段 Sex 必须是一个数字。" data-val-required="The Sex field is required." id="Sex" name="sex" type="radio" value="1" />男</label>
                    <label><input id="Sex" name="sex" type="radio" value="2" />女</label>
                </div>
            </div>
            
            <div class="control-group">
                <div class="controls"><button>确 &nbsp; 认</button></div>
            </div>
        </form>
    </div>
</div>



<link href="{{url('/ho/css/profile.css')}}" rel="stylesheet" type="text/css">



                </div>

            </div>

            


           
</div>
    </div>

</div>
<script type="text/javascript">
        //预览
            var result = document.getElementById("upload_prev");
            var input = document.getElementById("uploadPic");

            if(typeof FileReader === 'undefined'){
                result.innerHTML = "<p class='warn'>抱歉，你的浏览器不支持 FileReader</p>";
                input.setAttribute('disabled','disabled');
            }else{
                input.addEventListener('change',readFile,false);
            }
            
            function readFile(){
                var file = this.files[0];
                if(!/image\/\w+/.test(file.type)){
                    alert("请确保文件为图像类型");
                    return false;
                }
                var reader = new FileReader();
                reader.readAsDataURL(file);
                reader.onload = function(e){
                    result.innerHTML = '<img height="100px" src="'+this.result+'" alt=""/>'
                }
            }

        // 检测邮箱是否已注册
        $('#email').on('change',function(){
            var email = $(this).val();
            var span = $(this).next();
        $.ajax({
            type:"GET",
            url:"{{asset('/reg/ajax')}}",
            data:{email:email},
            success:function(data){
                if(data==2){
                    span.html('该邮箱已被注册，请更换邮箱！！');
                    span.css({color:'red'});
                }
            },
            error:function(){
                alert('异常');
            }
        });    
    });
        // 提交
    $('#btn_submit').on('click',function(){
        $('#personalProfileForm').submit();
    })

</script>
@endsection